package edu.hawaii.halealohacli;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.wattdepot.client.WattDepotClient;

/**
 * JUnit test used to check and test the EnergySince class.
 * 
 * @author John MacMillan
 * @author Mitchell Kupfer
 * @author Bryson Hori
 */
public class TestEnergySince {
  // URL to the WattDepot server
  String url = "http://server.wattdepot.org:8190/wattdepot/";
  // Create a WattDepotClient with URL
  WattDepotClient client = new WattDepotClient(url);
  String towerName = "Mokihana";
  String towerName2 = "Bar";
  String time = "2011-11-23";
  EnergySince energySince = new EnergySince(towerName, time, client);
  EnergySince errorEnergySince = new EnergySince(towerName2, time, client);

  /**
   * Checks to see if the values entered in the constructor for energy-since processes right.
   */
  @Test
  public void testValues() {
    assertEquals("Test to see if tower names match", towerName, energySince.getTower());
    assertEquals("Test to see if time match", time, energySince.getDate());
  }

  /**
   * Test the run method of energy-since to confirm that no errors occurred during execution.
   */
  @Test
  public void testRun() {
    try {
      assertTrue("Test run with good values", energySince.run());
      assertFalse("Test run with bad values", errorEnergySince.run());
    }
    catch (Exception e) {
      System.out.println("Error occured when running energy-since.");
    }
  }
}
